package com.bestcem.xm.ticket.enums;

import lombok.Getter;

/**
 * 组状态枚举
 *
 * @author ympan <yuming.pan@idiaoyan.com>
 * @version v1.0
 * @date 2021/8/26 18:24
 */
@Getter
public enum GroupStatusEnum {
    /**
     * 活动的
     */
    GROUP_STATUS_ACTIVATED("GROUP_STATUS_ACTIVATED", 0),

    /**
     * 禁用的
     */
    GROUP_STATUS_INACTIVATED("GROUP_STATUS_INACTIVATED", 1),

    /**
     * 隐藏
     */
    GROUP_STATUS_HIDDEN("GROUP_STATUS_HIDDEN", 2),

    /**
     * 已删除
     */
    GROUP_STATUS_DELETED("GROUP_STATUS_DELETED", 0);

    private final String name;

    private final Integer index;

    GroupStatusEnum(String name, Integer index) {
        this.name = name;
        this.index = index;
    }

    /**
     * 根据 index 获取枚举实体
     * 找不到则返回 null
     *
     * @param index 枚举index
     * @return 组状态 枚举
     * @author <yuming.pan@idiaoyan.com>
     * @date 19:58 2021/8/26
     */
    public static GroupStatusEnum getByIndex(Integer index) {
        for (GroupStatusEnum value : values()) {
            if (value.getIndex().equals(index)) {
                return value;
            }
        }
        return null;
    }
}
    